package com.local.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.local.model.Screen;
import com.local.model.ScreenDisplay;
import com.local.page.LocalScreenPage;
import com.local.service.face.LocalScreenService;
import com.qianhai.common.constants.CommonContans;
import com.qianhai.common.controller.BaseController;

@RestController
@RequestMapping(value = "/admin/screen", method = RequestMethod.POST)
public class LocalScreenController extends BaseController
{
	@Autowired
	private LocalScreenService localScreenService;
	
	/**
	 * 
	 * 方法描述：添加屏幕
	 * 
	 * @Title: addScreen
	 * @param @param crossing
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2016年4月25日
	 * @throws
	 */
	@RequestMapping(value = "/addScreen.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap addScreen(@RequestBody Screen screen)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			localScreenService.addScreen(screen);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/restById.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap restById(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			
			localScreenService.restById(uuid);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：删除屏幕
	 * 
	 * @Title: delCrossinById
	 * @param @param uuid
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2015年10月6日
	 * @throws
	 */
	@RequestMapping(value = "/delScreenById.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap delScreenById(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			
			localScreenService.delScreenById(uuid);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：
	 * 
	 * @Title: editCrossinById
	 * @param @param crossing
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2015年10月6日
	 * @throws
	 */
	@RequestMapping(value = "/editScreenById.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap editScreenById(@RequestBody Screen screen)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			localScreenService.editScreenById(screen);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：查询列表
	 * 
	 * @Title: queryScreenByPage
	 * @param @param page
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2016年4月25日
	 * @throws
	 */
	@RequestMapping(value = "/queryScreenByPage.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryScreenByPage(@RequestBody LocalScreenPage<Screen> page)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			localScreenService.queryScreenByPage(page);
			resultMap.put(CommonContans.STRUTS_DATA, page);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：根据ID查询
	 * 
	 * @Title: getScreenById
	 * @param @param uuid
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2016年4月25日
	 * @throws
	 */
	@RequestMapping(value = "/getScreenById.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap getScreenById(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			
			resultMap.put(CommonContans.STRUTS_DATA,
					localScreenService.getScreenById(uuid));
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/addOrModifyScreenDisplay.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap addOrModifyScreenDisplay(
			@RequestBody ScreenDisplay screenDisplay)
	
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			localScreenService.saveOrUpdateScreenDisplay(screenDisplay);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/LoadScreenDisplay.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap LoadScreenDisplay(@RequestBody ScreenDisplay screenDisplay)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			resultMap.put(CommonContans.STRUTS_DATA,
					localScreenService.queryScreenDisplay());
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
}
